function titleCase(str) {
    str = str
        .split(/\s+/)
        .map(item => {
            item = item.toLowerCase();
            return `${item.substr(0, 1).toUpperCase()}${item.substring(1)}`;
        })
        .join(" ");
    return str;
}

titleCase("I'm a little tea pot");
